//
//  NewSMTH.h
//  ViewPoint
//
//  Created by Demiao Lin on 08-10-23.
//  Copyright 2008 Tsinghua. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "TouchXML.h"

//#define IPSMTH_HOST @"ipsmth.appspot.com"
#define IPSMTH_HOST @"ismth.appspot.com"
//#define IPSMTH_HOST @"16.158.159.133:8080"
//#define IPSMTH_HOST @"localhost:8080"

@class DataStore;
@class Setting;


@interface Board : NSObject {
	NSString *bname;
	NSInteger *bid;
	NSString *desc;
	NSInteger *order;
	
}

@property (nonatomic, retain) NSString *bname;
@property (nonatomic) NSInteger *bid;
@property (nonatomic, retain) NSString *desc;
@property (nonatomic) NSInteger *order;

-(id) initWithName:(NSString*) board_name 
			   bid:(NSInteger*) board_id 
			 order:(NSInteger*) board_order
              desc:(NSString*) board_description;

-(id) initWithBoardName:(NSString*) board_name 
			        bid:(NSInteger*) board_id;
       
@end


@interface Thread : NSObject {
	NSString *title;
	NSInteger *tid;
}

@property (nonatomic, retain) NSString *title;
@property (nonatomic) NSInteger *tid;

-(id) initWithTitle:(NSString*) title 
			   tid:(NSInteger*) tid;

@end

@interface Post : NSObject {
	NSString *title;
	NSString *bname;
	NSInteger *bid;
	NSInteger *tid;
	NSInteger *pid;
	NSInteger *word_count;
	NSString *user;
	NSString *tag;
	NSString *date;
    NSString *content;
}

@property (nonatomic, retain) NSString *title;
@property (nonatomic, retain) NSString *bname;
@property (nonatomic) NSInteger *bid;
@property (nonatomic) NSInteger *tid;
@property (nonatomic) NSInteger *pid;
@property (nonatomic) NSInteger *word_count;
@property (nonatomic, retain) NSString *user;
@property (nonatomic, retain) NSString *tag;
@property (nonatomic, retain) NSString *date;
@property (nonatomic, retain) NSString *content;

-(id) initWithTitle:(NSString*) post_title
                tid:(NSInteger*) thread_id
				pid:(NSInteger*) post_id 
			   user:(NSString*) post_user 
				tag:(NSString*) post_tag 
			   date:(NSString*) post_date 
		 word_count:(NSInteger*) post_word_count;

-(id) initWithTitle:(NSString*) post_title 
				bid:(NSInteger*) board_id 
				pid:(NSInteger*) post_id 
			   user:(NSString*) post_user 
				tag:(NSString*) post_tag 
			   date:(NSString*) post_date 
		 word_count:(NSInteger*) post_word_count;

-(id) initWithTitle:(NSString*) post_title 
			  bname:(NSString*) board_name 
                bid:(NSInteger*) board_id 
				tid:(NSInteger*) thread_id 
			   user:(NSString*) post_user
			   date:(NSString*) post_date;
@end

@interface ArrayAndPageNum : NSObject {
	NSMutableArray *array;
	NSInteger page_num;
}

@property (nonatomic, retain) NSMutableArray *array;
@property (nonatomic) NSInteger page_num;

-(id) initWithArray:(NSMutableArray*) oneArray
		   page_num:(NSInteger) pagenum;

@end


@interface NewSMTH : NSObject {
    DataStore *dataStore;
	Setting *settings;
}
@property (nonatomic, retain) DataStore *dataStore;

+(NSData*) getContentDataFromURL: (NSString*)url;
+(NSString*) getContentFromURL: (NSString*)url;
//-(NSString*) getContentOfURL: (NSString*)url;
+(NSString*) stringWithURL:(NSString *)url;

+(NSString*) getPostContentFromBoardId:(NSInteger*)board_id 
                               post_id:(NSInteger*)post_id 
                             post_type:(NSString*)post_type;

-(Board*) getBoardWithName:(NSString*)board_name;

-(NSMutableArray *) getBoards;
-(NSMutableArray *) getTop10Posts;
-(ArrayAndPageNum *) getPostsWithBoardName:(NSString*)board_name
                                  page_num:(NSInteger)page_num;
-(ArrayAndPageNum *) getThreadsWithBoardName:(NSString*)board_name
                                  page_num:(NSInteger)page_num;
-(Post*) getPostWithBoardId:(NSInteger*)board_id 
                    post_id:(NSInteger*)post_id 
                  post_type:(NSString*)post_type;
-(NSString*) getCssStyle;
@end
